﻿@using OBUCare.Core.Models
@using OBUCare.Web.Models
@using OBUCare.Web.Infrastructure
@{
    var menuName = PageData["moduleID"];
    ViewData["menuName"] = menuName;
}
<h2>@ViewBag.Title</h2>
<link href="../../Content/tableCss.css" rel="stylesheet" type="text/css" />
<table width="100%">
    <tr>
        <td style="text-align: center">
            <span class="pTitle">营业厅维修业务日报</span>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td style="text-align: center">
            @Html.Partial("_DailySearch", ViewData["menuName"])
        </td>
    </tr>
    <tr>
        <td style="text-align: left">
            @(Html.Telerik().Grid<View_Operator_InvoiceInfos>()
        .Name("Grid")
                    //.DataKeys(keys => keys.Add(c => c.op))
        .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
        .DataBinding(dataBinding => dataBinding
            .Ajax()
            .Select("ListOperatorInvoicesSqlItems", "Report", new { sql = "" })
                    )
        .Columns(columns =>
        {
            columns.Bound(o => o.AGENT_NO).Title("序号").ClientTemplate("<#= ++index #>").Width("5%");
            columns.Bound(o => o.RECORD_TIME).Format("{0:yyyy-MM-dd}").Width("10%");
            columns.Bound(o => o.AGENT_NAME).Width("10%");
            columns.Bound(o => o.OPERATOR_NAME).Width("10%");
            columns.Bound(o => o.FeeType).Width("10%");
            columns.Bound(o => o.FUND_AMOUNT).Width("8%");
            columns.Bound(o => o.StatetaxCount).Width("8%");
            columns.Bound(o => o.StatetaxAmount).Width("8%");
            columns.Bound(o => o.LocaltaxCount).Width("8%");
            columns.Bound(o => o.LocaltaxAmount).Width("8%");
            columns.Bound(o => o.ReceipttaxCount).Width("8%");
            columns.Bound(o => o.ReceipttaxAmount).Width("8%");
        }).TableHtmlAttributes(new { @style = "width:160%" })
        .ClientEvents(events =>
        {
            events.OnError("onError");
            events.OnDataBinding("onDataBinding");
        })
        .Pageable(paging =>
        {
            paging.Style(CommonStyleForUI.Grid_PageStyle)
            .Position(CommonStyleForUI.Grid_PagePosition)
            .PageTo(CommonStyleForUI.Grid_CurrentPage)
            .PageSize(CommonStyleForUI.Grid_PageSize);
        })
                    //.Resizable(resizing => resizing.Columns(true))
        .Scrollable(scroll => scroll.Height(CommonStyleForUI.Grid_Height))
                    //.Selectable()
)
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td style="text-align: left">
            @(Html.Telerik().Grid<View_Received_Returned_Money>()
        .Name("GridMoney")
                    //.DataKeys(keys => keys.Add(c => c.op))
        .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
        .DataBinding(dataBinding => dataBinding
            .Ajax()
            .Select("ListOperatorReceivedReturnedMoneySqlItems", "Report", new { sql = "" })
                    )
        .Columns(columns =>
        {
            columns.Bound(o => o.AGENT_NO).Title("序号").ClientTemplate("<#= ++indexMoney #>").Width("4%");
            columns.Bound(o => o.RECORD_TIME).Format("{0:yyyy-MM-dd}").Width("8%");
            columns.Bound(o => o.AGENT_NAME).Width("8%");
            columns.Bound(o => o.OPERATOR_NAME).Width("5%");
            columns.Bound(o => o.from_0).Width("6%");
            columns.Bound(o => o.from_1).Width("6%");
            columns.Bound(o => o.from_2).Width("6%");
            columns.Bound(o => o.from_3).Width("6%");
            columns.Bound(o => o.from_4).Width("6%");
            columns.Bound(o => o.from_5).Width("6%");
            columns.Bound(o => o.from_10).Width("6%");
            columns.Bound(o => o.AmountAll).Width("6%");
            columns.Bound(o => o.ReturnedAmount).Width("6%");
            columns.Bound(o => o.ReturnToFinance).Width("6%");
            columns.Bound(o => o.ReturnedAllAmount).Width("6%");
        }).TableHtmlAttributes(new { @style = "width:180%" })
        .ClientEvents(events =>
        {
            events.OnError("onError");
            events.OnDataBinding("onGridMoneyDataBinding");
        })
        .Pageable(paging =>
        {
            paging.Style(CommonStyleForUI.Grid_PageStyle)
            .Position(CommonStyleForUI.Grid_PagePosition)
            .PageTo(CommonStyleForUI.Grid_CurrentPage)
            .PageSize(CommonStyleForUI.Grid_PageSize);
        })
                    //.Resizable(resizing => resizing.Columns(true))
        .Scrollable(scroll => scroll.Height(CommonStyleForUI.Grid_Height))
                    //.Selectable()
)
        </td>
    </tr>
</table>
<script type="text/javascript">
    function onError(e) {
        //debugger;
        e.preventDefault();
        /*if (e.XMLHttpRequest.status == "505")
        alert("系统字段不允许删除");
        else if (e.XMLHttpRequest.status == "506")
        alert("系统表不允许删除");
        else*/
        alert(e.XMLHttpRequest.getResponseHeader("message"));
    }

    var index = 0;

    function onDataBinding(e) {
        var grid = $('#Grid').data('tGrid')
        index = (grid.currentPage - 1) * grid.pageSize;
        e.data = {
            // the key ("category") specifies the variable name of the action method which will contain the specified value
            searchSql: $('#searchSql').val(),
            agentNO: $('#agentNO').val(),
            menuNames: $('#menuNames').val()
        };
    }

    var indexMoney = 0;

    function onGridMoneyDataBinding(e) {
        var grid = $('#GridMoney').data('tGrid')
        indexMoney = (grid.currentPage - 1) * grid.pageSize;
        e.data = {
            // the key ("category") specifies the variable name of the action method which will contain the specified value
            searchSql: $('#searchSql').val(),
            agentNO: $('#agentNO').val(),
            menuNames:$('#menuNames').val()
        };
    }
</script>
